/*
 * Copyright 2009 Thor Hovden
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *     http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific
 * language governing permissions and limitations under the
 * License. 
 */
package dev.sketch.needs;

import java.lang.reflect.Method;
import java.util.ArrayList;

/**
 * Represents a need someone has, which this application aims to solve.
 * <tt>As a XXX I need YYY in order to ZZZ</tt>
 * <p>
 * Oh, nevermind to do this in Java, why not use Eviva for it? :D:D:D:D<br>
 * Ahh, forgot my main purpose to code in Java; that we will be able to reference a need definition in code where
 * we implement stuff. Check UserNeeds.java. Hm, maybe best to call need implementors from Junit test? This way
 * would make us use TDD and top it with requirement formulations.
 * 
 * @author Thor Hovden
 */
public class Need {

	protected String role;
	protected String need;
	protected String purpose;
	protected ArrayList<Method> implementors;

	public Need(String role, String need, String purpose) {
		this.role = role;
		this.need = need;
		this.purpose = purpose;
	}

	public String getRole() {
		return role;
	}

	public String getNeed() {
		return need;
	}

	public String getPurpose() {
		return purpose;
	}

	public String toString() {
		return "As a " + role + ", I need " + need + " in order to " + purpose;
	}

	/**
	 * Add method to list of implementors
	 * 
	 * @param method
	 * @return string representation of this fact (for easy inclusion into MissionControl.log)
	 */
	public String implementedBy(Method method) {
		implementors.add(method);
		return "Method " + method.getClass().getName() + "#" + method.getName() + "() implements " + toString();
	}

	public ArrayList<Method> getImplementors() {
		return implementors;
	}
}
